package com.leyou.item.inter.api;

import com.leyou.common.bean.PageResult;
import com.leyou.common.bean.Result;
import com.leyou.common.bean.ServerConstant;
import com.leyou.item.inter.dto.SpuPageDTO;
import com.leyou.item.inter.dto.SpuSaveDTO;
import com.leyou.item.inter.fallback.GoodsServiceFallbackFactory;
import com.leyou.item.inter.pojo.Sku;
import com.leyou.item.inter.pojo.Spu;
import com.leyou.item.inter.pojo.SpuDetail;
import com.leyou.item.inter.vo.SpuBoVO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zqq
 * @ClassName IGoodsService
 * @Description
 * @date 2020/3/7-16:37
 */
@Component
@FeignClient(value = ServerConstant.ITEM_SERVICE_ID, fallbackFactory = GoodsServiceFallbackFactory.class)
public interface IGoodsService {

    @RequestMapping(value = "/spu/page", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<PageResult<SpuBoVO>> querySpuBoByPage(@RequestBody SpuPageDTO dto);

    @RequestMapping(value = "/add/goods", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result saveGoods(@RequestBody SpuSaveDTO dto);

    @RequestMapping(value = "/spu/detail/{spuId}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<SpuDetail> querySpuDetailBySpuId(@PathVariable("spuId") Long spuId);

    @RequestMapping(value = "/sku/list/{spuId}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<List<Sku>> querySkusBySpuId(@PathVariable("spuId") Long spuId);

    @RequestMapping(value = "/enable/sku/list/{spuId}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<List<Sku>> queryEnableSkusBySpuId(@PathVariable("spuId") Long spuId);

    @RequestMapping(value = "/update/goods", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result updateGoods(@RequestBody SpuSaveDTO dto);

    @RequestMapping(value = "/spu/{id}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<Spu> querySpuById(@PathVariable("id") Long id);

    @RequestMapping(value = "/sku/{id}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<Sku> querySkuById(@PathVariable("id") Long id);
}
